package com.navinfo.opentsp.platform.computing.serializer;

import com.alibaba.fastjson.JSON;
import com.navinfo.opentsp.platform.computing.dto.IncidentAlermData;
import org.apache.commons.lang.ArrayUtils;
import org.apache.flume.Context;
import org.apache.flume.Event;
import org.apache.flume.conf.ComponentConfiguration;
import org.apache.flume.sink.hbase.AsyncHbaseEventSerializer;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.schema.types.*;
import org.hbase.async.AtomicIncrementRequest;
import org.hbase.async.PutRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * flink驾驶行为分析2.0计算异步序列化
 */
public class AsyncHbaseincidentAlarmSerializer implements AsyncHbaseEventSerializer {
    private static final Logger log = LoggerFactory.getLogger(AsyncHbaseincidentAlarmSerializer.class);
    private byte[] table;
    private byte[] colFam = Bytes.toBytes("0");
    private Event currentEvent;

    @Override
    public void initialize(byte[] table, byte[] colFam) {
        this.table = table;
        this.colFam = colFam;
    }

    @Override
    public void setEvent(Event event) {
        this.currentEvent = event;
    }

    @Override
    public void configure(Context context) {
    }
    @Override
    public void configure(ComponentConfiguration componentConfiguration) {
    }
    @Override
    public void cleanUp() {    }

    @Override
    public List<PutRequest> getActions() {
        List<PutRequest> actions = new ArrayList();
        try {
            IncidentAlermData incidentAlermData = JSON.parseObject(currentEvent.getBody(), IncidentAlermData.class);

            //rowkey:reverse(tId)|3000000000L-gpsTime
            //reverse(tId)实现rowkey的散列，3000000000L-gpsTime实现逆序最新记录在头部
//            String rowKey = new StringBuilder(Long.valueOf(incidentAlermData.getTid()).toString()).reverse() + "\\x00"+incidentAlermData.getDay()+"\\x00" + (3000000000L - incidentAlermData.getRouteStartTime());
            //落盘phoenix时，phoenix主键 reverse(tId)+day+3000000000L-beginTime.
            //phoenix主键分隔符为\x00，所以各个主键字段分隔符为16进制的 0 （即\x00）
            String tidreverse = new StringBuilder(Long.valueOf(incidentAlermData.getTid()).toString()).reverse().toString();
            byte[] tid = Bytes.toBytes(tidreverse);
            byte sep = (byte) 0;
            byte[] seperate = new byte[] {sep};
            byte[] rowKeyByte = ArrayUtils.addAll(tid,seperate);
            byte[] day = Bytes.toBytes(incidentAlermData.getTripDay());
            byte[] rowKeyByte1 = ArrayUtils.addAll(rowKeyByte,day);
            byte[] rowKeyByte2 = ArrayUtils.addAll(rowKeyByte1,seperate);
            byte[] startTime = Bytes.toBytes(String.valueOf(3000000000L - incidentAlermData.getRouteStartTime()));
            byte[] rowKeyByte3 = ArrayUtils.addAll(rowKeyByte2,startTime);


                    //添加PutRequest
                    actions.add(preparedata(rowKeyByte3, incidentAlermData));
        } catch (Exception e) {
            log.error("flink驾驶行为分析2.0计算异步序列化失败：" + e.getMessage(), e);
        }

        return actions;
    }

    /**
     * 处理数据
     * @param rowKey
     * @throws Exception
     */
    private PutRequest preparedata(byte[] rowKey, IncidentAlermData incidentAlermData) throws Exception {
        try{


        byte[][] qualifiers = new byte[101][];
        byte[][] values = new byte[101][];

        qualifiers[0] = Bytes.toBytes("TID")                     ;
        qualifiers[1] = Bytes.toBytes("TRIPID");
        qualifiers[2] = Bytes.toBytes("TRIP_DAY")                     ;
        qualifiers[3] = Bytes.toBytes("ROUTE_START_TIME");
        qualifiers[4] = Bytes.toBytes("ROUTE_START_LC")          ;
        qualifiers[5] = Bytes.toBytes("ROUTE_START_LATITUDE")    ;
        qualifiers[6] = Bytes.toBytes("ROUTE_START_LONGITUDE")   ;
        qualifiers[7] = Bytes.toBytes("ROUTE_START_HEIGHT")      ;
        qualifiers[8] = Bytes.toBytes("ROUTE_START_DIRECTION")   ;
        qualifiers[9] = Bytes.toBytes("ROUTE_START_MILEAGE")     ;
        qualifiers[10] =Bytes.toBytes("ROUTE_START_FUEL")        ;
        qualifiers[11] =Bytes.toBytes("ROUTE_END_TIME")          ;
        qualifiers[12] =Bytes.toBytes("ROUTE_END_LC")            ;
        qualifiers[13] =Bytes.toBytes("ROUTE_END_LATITUDE")      ;
        qualifiers[14] =Bytes.toBytes("ROUTE_END_LONGITUDE")     ;
        qualifiers[15] =Bytes.toBytes("ROUTE_END_HEIGHT")        ;
        qualifiers[16] =Bytes.toBytes("ROUTE_END_DIRECTION")     ;
        qualifiers[17] =Bytes.toBytes("ROUTE_END_MILEAGE");
        qualifiers[18] =Bytes.toBytes("ROUTE_END_FUEL")          ;
        qualifiers[19] =Bytes.toBytes("ROUTE_INTEGRAL_MILEAGE")  ;
        qualifiers[20] =Bytes.toBytes("ROUTE_INTEGRAL_FUEL")     ;
        qualifiers[21] =Bytes.toBytes("ROUTE_INTEGRAL_DURATION") ;
        qualifiers[22] =Bytes.toBytes("TRIP_MILEAGE");
        qualifiers[23] =Bytes.toBytes("TRIP_FUEL")               ;
        qualifiers[24] =Bytes.toBytes("TRIP_DURATION")           ;
        qualifiers[25] =Bytes.toBytes("TRIP_POWER")              ;
        qualifiers[26] =Bytes.toBytes("PRECISE_FLAG");
        qualifiers[27] =Bytes.toBytes("S_TYPE");
        qualifiers[28] =Bytes.toBytes("CROSS_DAY_FLAG")          ;
        qualifiers[29] =Bytes.toBytes("SHARP_TURNING_NUMBER")    ;
        qualifiers[30] =Bytes.toBytes("NIGHT_RUNNING_NUMBER")    ;
        qualifiers[31] =Bytes.toBytes("EMERGENCY_STOP_NUMBER")   ;
        qualifiers[32] =Bytes.toBytes("FLAMEOUT_COAST_NUMBER")   ;
        qualifiers[33] =Bytes.toBytes("COLD_RUNNING_MILEAGE")    ;
        qualifiers[34] =Bytes.toBytes("COLD_RUNNING_FUEL")       ;
        qualifiers[35] =Bytes.toBytes("COLD_RUNNING_DURATION")   ;
        qualifiers[36] =Bytes.toBytes("COLD_RUNNING_NUMBER")     ;
        qualifiers[37] =Bytes.toBytes("NO_ECO_DRIVING_MILEAGE")  ;
        qualifiers[38] =Bytes.toBytes("NO_ECO_DRIVING_FUEL")     ;
        qualifiers[39] =Bytes.toBytes("NO_ECO_DRIVING_DURATION") ;
        qualifiers[40] =Bytes.toBytes("NO_ECO_DRIVING_NUMBER")   ;
        qualifiers[41] =Bytes.toBytes("NO_ECO_DRIVING_PROPORTION")       ;
        qualifiers[42] =Bytes.toBytes("FATIGUE_DRIVING_NUMBER")  ;
        qualifiers[43] =Bytes.toBytes("FATIGUE_DRIVING_DURATION");
        qualifiers[44] =Bytes.toBytes("FUEL_100KM");
        qualifiers[45] =Bytes.toBytes("SHARPUP_SPEED_NUMBER_100KM");
        qualifiers[46] =Bytes.toBytes("SHARPDOWN_SPEED_NUMBER_100KM");
        qualifiers[47] =Bytes.toBytes("SHARP_TURNING_NUMBER_100KM");
        qualifiers[48] =Bytes.toBytes("EMERGENCY_STOP_NUMBER_100KM");
        qualifiers[49] =Bytes.toBytes("FLAMEOUT_COAST_NUMBER_100KM");
        qualifiers[50] =Bytes.toBytes("SPEEDOVER_DURATION_HOURLY");
        qualifiers[51] =Bytes.toBytes("LONGIDLE_DURATION_HOURLY");
        qualifiers[52] =Bytes.toBytes("LARGEGAS_DURATION_HOURLY");
        qualifiers[53] =Bytes.toBytes("NOECO_DURATION_HOURLY");
        qualifiers[54] =Bytes.toBytes("NEUTRAL_GEAR_COAST_DURATION_HOURLY");
        qualifiers[55] =Bytes.toBytes("FATIGUE_DRIVING_DURATION_HOURLY");
        qualifiers[56] =Bytes.toBytes("NIGHT_RUNNING_DURATION_HOURLY");
        qualifiers[57] =Bytes.toBytes("IDLE_CONDITION_FUEL");
        qualifiers[58] =Bytes.toBytes("IDLE_CONDITION_DURATION");
        qualifiers[59] =Bytes.toBytes("LOW_CONDITION_FUEL");
        qualifiers[60] =Bytes.toBytes("LOW_CONDITION_DURATION");
        qualifiers[61] =Bytes.toBytes("LOW_CONDITION_SPEEDAVG");
        qualifiers[62] =Bytes.toBytes("LOW_CONDITION_SPEEDSTDEV");
        qualifiers[63] =Bytes.toBytes("LOW_CONDITION_ACCELERATIONAVG");
        qualifiers[64] =Bytes.toBytes("LOW_CONDITION_ACCELERATIONSTDEV");
        qualifiers[65] =Bytes.toBytes("LOW_CONDITION_RPMAVG");
        qualifiers[66] =Bytes.toBytes("LOW_CONDITION_RPMSTDEV");
        qualifiers[67] =Bytes.toBytes("LOW_CONDITION_THROTTLE_AVG");
        qualifiers[68] =Bytes.toBytes("LOW_CONDITION_THROTTLE_STDEV");
        qualifiers[69] =Bytes.toBytes("LOW_CONDITION_THROTTLE_RATEAVG");
        qualifiers[70] =Bytes.toBytes("LOW_CONDITION_THROTTLE_RATESTDEV");
        qualifiers[71] =Bytes.toBytes("ACCELERATE_CONDITION_FUEL");
        qualifiers[72] =Bytes.toBytes("ACCELERATE_CONDITION_DURATION");
        qualifiers[73] =Bytes.toBytes("ACCELERATE_CONDITION_SPEEDAVG");
        qualifiers[74] =Bytes.toBytes("ACCELERATE_CONDITION_SPEEDSTDEV");
        qualifiers[75] =Bytes.toBytes("ACCELERATE_CONDITION_ACCELERATIONAVG");
        qualifiers[76] =Bytes.toBytes("ACCELERATE_CONDITION_ACCELERATIONSTDEV");
        qualifiers[77] =Bytes.toBytes("ACCELERATE_CONDITION_RPMAVG");
        qualifiers[78] =Bytes.toBytes("ACCELERATE_CONDITION_RPMSTDEV");
        qualifiers[79] =Bytes.toBytes("ACCELERATE_CONDITION_THROTTLEAVG");
        qualifiers[80] =Bytes.toBytes("ACCELERATE_CONDITION_THROTTLESTDEV");
        qualifiers[81] =Bytes.toBytes("ACCELERATE_CONDITION_THROTTLERATEAVG");
        qualifiers[82] =Bytes.toBytes("ACCELERATE_CONDITION_THROTTLERATESTDEV");
        qualifiers[83] =Bytes.toBytes("DECELERATE_CONDITION_FUEL");
        qualifiers[84] =Bytes.toBytes("DECELERATE_CONDITION_DURATION");
        qualifiers[85] =Bytes.toBytes("DECELERATE_CONDITION_SPEEDAVG");
        qualifiers[86] =Bytes.toBytes("DECELERATE_CONDITION_SPEEDSTDEV");
        qualifiers[87] =Bytes.toBytes("DECELERATE_CONDITION_ACCELERATIONAVG");
        qualifiers[88] =Bytes.toBytes("DECELERATE_CONDITION_ACCELERATIONSTDEV");
        qualifiers[89] =Bytes.toBytes("UNIFORM_CONDITION_FUEL");
        qualifiers[90] =Bytes.toBytes("UNIFORM_CONDITION_DURATION");
        qualifiers[91] =Bytes.toBytes("UNIFORM_CONDITION_SPEEDAVG");
        qualifiers[92] =Bytes.toBytes("UNIFORM_CONDITION_SPEEDSTDEV");
        qualifiers[93] =Bytes.toBytes("UNIFORM_CONDITION_ACCELERATIONAVG");
        qualifiers[94] =Bytes.toBytes("UNIFORM_CONDITION_ACCELERATIONSTDEV");
        qualifiers[95] =Bytes.toBytes("UNIFORM_CONDITION_RPMAVG");
        qualifiers[96] =Bytes.toBytes("UNIFORM_CONDITION_RPMSTDEV");
        qualifiers[97] =Bytes.toBytes("UNIFORM_CONDITION_THROTTLEAVG");
        qualifiers[98] =Bytes.toBytes("UNIFORM_CONDITION_THROTTLESTDEV");
        qualifiers[99] =Bytes.toBytes("UNIFORM_CONDITION_THROTTLERATEAVG");
        qualifiers[100] =Bytes.toBytes("UNIFORM_CONDITION_THROTTLERATESTDEV");


        values[0] = Bytes.toBytes(String.valueOf(incidentAlermData.getTid()));
        values[1] = Bytes.toBytes(String.valueOf(incidentAlermData.getTripId()));
        values[2] = Bytes.toBytes(String.valueOf(incidentAlermData.getTripDay()));
        values[3] = Bytes.toBytes(String.valueOf(incidentAlermData.getRouteStartTime()));
        values[4] = Bytes.toBytes(String.valueOf(incidentAlermData.getRouteStartLc()));
        values[5] = Bytes.toBytes(String.valueOf(incidentAlermData.getRouteStartLatitude()));
        values[6] = Bytes.toBytes(String.valueOf(incidentAlermData.getRouteStartLongitude()));
        values[7] = Bytes.toBytes(String.valueOf(incidentAlermData.getRouteStartHeight()));
        values[8] = Bytes.toBytes(String.valueOf(incidentAlermData.getRouteStartDirection()));
        values[9] = Bytes.toBytes(String.valueOf(incidentAlermData.getRouteStartMileage()));
        values[10] = Bytes.toBytes(String.valueOf(incidentAlermData.getRouteStartFuel()));
        values[11] =Bytes.toBytes(String.valueOf(3000000000L - incidentAlermData.getRouteEndTime()));
        values[12] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteEndLc()));
        values[13] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteEndLatitude()));
        values[14] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteEndLongitude()));
        values[15] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteEndHeight()));
        values[16] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteEndDirection()));
        values[17] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteEndMileage()));
        values[18] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteEndFuel()));
        values[19] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteIntegralMileage()));
        values[20] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteIntegralFuel()));
        values[21] =Bytes.toBytes(String.valueOf(incidentAlermData.getRouteIntegralDuration()));
        values[22] =Bytes.toBytes(String.valueOf(incidentAlermData.getTripMileage()));
        values[23] =Bytes.toBytes(String.valueOf(incidentAlermData.getTripFuel()));
        values[24] =Bytes.toBytes(String.valueOf(incidentAlermData.getTripDuration()));
        values[25] =Bytes.toBytes(String.valueOf(incidentAlermData.getTripPower()));
        values[26] =Bytes.toBytes(String.valueOf(incidentAlermData.getPreciseFlag()));
        values[27] =Bytes.toBytes(String.valueOf(incidentAlermData.getsType()));
        values[28] =Bytes.toBytes(String.valueOf(incidentAlermData.getCrossDayFlag()));
        values[29] =Bytes.toBytes(String.valueOf(incidentAlermData.getSharpTurningNumber()));
        values[30] =Bytes.toBytes(String.valueOf(incidentAlermData.getNightRunningNumber()));
        values[31] =Bytes.toBytes(String.valueOf(incidentAlermData.getEmergencyStopNumber()));
        values[32] =Bytes.toBytes(String.valueOf(incidentAlermData.getFlameoutCoastNumber()));
        values[33] =Bytes.toBytes(String.valueOf(incidentAlermData.getColdRunningMileage()));
        values[34] =Bytes.toBytes(String.valueOf(incidentAlermData.getColdRunningFuel()));
        values[35] =Bytes.toBytes(String.valueOf(incidentAlermData.getColdRunningDuration()));
        values[36] =Bytes.toBytes(String.valueOf(incidentAlermData.getColdRunningNumber()));
        values[37] =Bytes.toBytes(String.valueOf(incidentAlermData.getNoEcoDrivingMileage()));
        values[38] =Bytes.toBytes(String.valueOf(incidentAlermData.getNoEcoDrivingFuel()));
        values[39] =Bytes.toBytes(String.valueOf(incidentAlermData.getNoEcoDrivingDuration()));
        values[40] =Bytes.toBytes(String.valueOf(incidentAlermData.getNoEcoDrivingNumber()));
        values[41] =Bytes.toBytes(String.valueOf(incidentAlermData.getNoEcoDrivingProportion()));
        values[42] =Bytes.toBytes(String.valueOf(incidentAlermData.getFatigueDrivingNumber()));
        values[43] =Bytes.toBytes(String.valueOf(incidentAlermData.getFatigueDrivingDuration()));
        values[44] =Bytes.toBytes(String.valueOf(incidentAlermData.getFuel100KM()));
        values[45] =Bytes.toBytes(String.valueOf(incidentAlermData.getSharpUpSpeedNumber100KM()));
        values[46] =Bytes.toBytes(String.valueOf(incidentAlermData.getSharpDownSpeedNumber100KM()));
        values[47] =Bytes.toBytes(String.valueOf(incidentAlermData.getSharpTurningNumber100KM()));
        values[48] =Bytes.toBytes(String.valueOf(incidentAlermData.getEmergencyStopNumber100KM()));
        values[49] =Bytes.toBytes(String.valueOf(incidentAlermData.getFlameOutCoastNumber100KM()));
        values[50] =Bytes.toBytes(String.valueOf(incidentAlermData.getSpeedOverDurationHourly()));
        values[51] =Bytes.toBytes(String.valueOf(incidentAlermData.getLongIdleDurationHourly()));
        values[52] =Bytes.toBytes(String.valueOf(incidentAlermData.getLargeGasDurationHourly()));
        values[53] =Bytes.toBytes(String.valueOf(incidentAlermData.getNoEcoDurationHourly()));
        values[54] =Bytes.toBytes(String.valueOf(incidentAlermData.getNeutralGearCoastDurationHourly()));
        values[55] =Bytes.toBytes(String.valueOf(incidentAlermData.getFatigueDrivingDurationHourly()));
        values[56] =Bytes.toBytes(String.valueOf(incidentAlermData.getNightRunningDurationHourly()));
        values[57] =Bytes.toBytes(String.valueOf(incidentAlermData.getIdleConditionFuel()));
        values[58]=Bytes.toBytes(String.valueOf(incidentAlermData.getIdleConditionDuration()));
        values[59]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionFuel()));
        values[60]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionDuration()));
        values[61]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionSpeedAvg()));
        values[62]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionSpeedStDev()));
        values[63]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionAccelerationAvg()));
        values[64]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionAccelerationStDev()));
        values[65]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionRpmAvg()));
        values[66]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionRpmStDev()));
        values[67]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionThrottleAvg()));
        values[68]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionThrottleStDev()));
        values[69]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionThrottleRateAvg()));
        values[70]=Bytes.toBytes(String.valueOf(incidentAlermData.getLowConditionThrottleRateStDev()));
        values[71]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionFuel()));
        values[72]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionDuration()));
        values[73]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionSpeedAvg()));
        values[74]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionSpeedStDev()));
        values[75]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionAccelerationAvg()));
        values[76]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionAccelerationStDev()));
        values[77]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionRpmAvg()));
        values[78]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionRpmStDev()));
        values[79]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionThrottleAvg()));
        values[80]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionThrottleStDev()));
        values[81]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionThrottleRateAvg()));
        values[82]=Bytes.toBytes(String.valueOf(incidentAlermData.getAccelerateConditionThrottleRateStDev()));
        values[83]=Bytes.toBytes(String.valueOf(incidentAlermData.getDecelerateConditionFuel()));
        values[84]=Bytes.toBytes(String.valueOf(incidentAlermData.getDecelerateConditionDuration()));
        values[85]=Bytes.toBytes(String.valueOf(incidentAlermData.getDecelerateConditionSpeedAvg()));
        values[86]=Bytes.toBytes(String.valueOf(incidentAlermData.getDecelerateConditionSpeedStDev()));
        values[87]=Bytes.toBytes(String.valueOf(incidentAlermData.getDecelerateConditionAccelerationAvg()));
        values[88]=Bytes.toBytes(String.valueOf(incidentAlermData.getDecelerateConditionAccelerationStDev()));
        values[89]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionFuel()));
        values[90]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionDuration()));
        values[91]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionSpeedAvg()));
        values[92]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionSpeedStDev()));
        values[93]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionAccelerationAvg()));
        values[94]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionAccelerationStDev()));
        values[95]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionRpmAvg()));
        values[96]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionRpmStDev()));
        values[97]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionThrottleAvg()));
        values[98]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionThrottleStDev()));
        values[99]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionThrottleRateAvg()));
        values[100]=Bytes.toBytes(String.valueOf(incidentAlermData.getUniformConditionThrottleRateStDev()));


//        values[0] = encodeLong(String.valueOf(incidentAlermData.getTid()));
//        values[1] = encodeInteger(String.valueOf(incidentAlermData.getTripId()));
//        values[2] = encodeVarchar(String.valueOf(incidentAlermData.getDay()));
//        values[3] = encodeLong(String.valueOf(incidentAlermData.getRouteStartTime()));
//        values[4] = encodeInteger(String.valueOf(incidentAlermData.getRouteStartLc()));
//        values[5] = encodeInteger(String.valueOf(incidentAlermData.getRouteStartLatitude()));
//        values[6] = encodeInteger(String.valueOf(incidentAlermData.getRouteStartLongitude()));
//        values[7] = encodeInteger(String.valueOf(incidentAlermData.getRouteStartHeight()));
//        values[8] = encodeInteger(String.valueOf(incidentAlermData.getRouteStartDirection()));
//        values[9] = encodeInteger(String.valueOf(incidentAlermData.getRouteStartMileage()));
//        values[10] =encodeInteger(String.valueOf(incidentAlermData.getRouteStartFuel()));
//        values[11] =encodeLong(String.valueOf(incidentAlermData.getRouteEndTime()));
//        values[12] =encodeInteger(String.valueOf(incidentAlermData.getRouteEndLc()));
//        values[13] =encodeInteger(String.valueOf(incidentAlermData.getRouteEndLatitude()));
//        values[14] =encodeInteger(String.valueOf(incidentAlermData.getRouteEndLongitude()));
//        values[15] =encodeInteger(String.valueOf(incidentAlermData.getRouteEndHeight()));
//        values[16] =encodeInteger(String.valueOf(incidentAlermData.getRouteEndDirection()));
//        values[17] =encodeInteger(String.valueOf(incidentAlermData.getRouteEndMileage()));
//        values[18] =encodeInteger(String.valueOf(incidentAlermData.getRouteEndFuel()));
//        values[19] =encodeInteger(String.valueOf(incidentAlermData.getRouteIntegralMileage()));
//        values[20] =encodeInteger(String.valueOf(incidentAlermData.getRouteIntegralFuel()));
//        values[21] =encodeInteger(String.valueOf(incidentAlermData.getRouteIntegralDuration()));
//        values[22] =encodeInteger(String.valueOf(incidentAlermData.getTripMileage()));
//        values[23] =encodeInteger(String.valueOf(incidentAlermData.getTripFuel()));
//        values[24] =encodeInteger(String.valueOf(incidentAlermData.getTripDuration()));
//        values[25] =encodeInteger(String.valueOf(incidentAlermData.getTripPower()));
//        values[26] =encodeInteger(String.valueOf(incidentAlermData.getPreciseFlag()));
//        values[27] =encodeInteger(String.valueOf(incidentAlermData.getCrossDayFlag()));
//        values[28] =encodeInteger(String.valueOf(incidentAlermData.getSharpTurningNumber()));
//        values[29] =encodeInteger(String.valueOf(incidentAlermData.getNightRunningNumber()));
//        values[30] =encodeInteger(String.valueOf(incidentAlermData.getEmergencyStopNumber()));
//        values[31] =encodeInteger(String.valueOf(incidentAlermData.getFlameoutCoastNumber()));
//        values[32] =encodeInteger(String.valueOf(incidentAlermData.getColdRunningMileage()));
//        values[33] =encodeInteger(String.valueOf(incidentAlermData.getColdRunningFuel()));
//        values[34] =encodeInteger(String.valueOf(incidentAlermData.getColdRunningDuration()));
//        values[35] =encodeInteger(String.valueOf(incidentAlermData.getColdRunningNumber()));
//        values[36] =encodeInteger(String.valueOf(incidentAlermData.getNoEcoDrivingMileage()));
//        values[37] =encodeInteger(String.valueOf(incidentAlermData.getNoEcoDrivingFuel()));
//        values[38] =encodeInteger(String.valueOf(incidentAlermData.getNoEcoDrivingDuration()));
//        values[39] =encodeInteger(String.valueOf(incidentAlermData.getNoEcoDrivingNumber()));
//        values[40] =encodeInteger(String.valueOf(incidentAlermData.getNoEcoProportion()));
//        values[41] =encodeInteger(String.valueOf(incidentAlermData.getFatigueDrivingNumber()));
//        values[42] =encodeInteger(String.valueOf(incidentAlermData.getFatigueDrivingDuration()))
          return new PutRequest(table,rowKey, colFam, qualifiers, values);

        }catch(Exception e){
            log.error("执行拦截器失败 AsyncHbaseincidentAlarmSerializer error:" +e.getMessage(),e);
        }
          return null;
    }

    @Override
    public List<AtomicIncrementRequest> getIncrements() {
        return new ArrayList<AtomicIncrementRequest>();
    }

    public static byte[] encodeDecimal(String value)
    {
        BigDecimal bigDecValue = new BigDecimal(value);
        byte[] pDecimalByteArray = PDecimal.INSTANCE.toBytes(bigDecValue);
        return pDecimalByteArray;
    }

    public static byte[] encodeDate(java.util.Date utilDate)
    {
        java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
        byte[] pDateByteArray = PDate.INSTANCE.toBytes(sqlDate);
        return pDateByteArray;
    }

    public static byte[] encodeTimestamp(String utilTS)
    {
        java.sql.Timestamp sqlDate = Timestamp.valueOf(utilTS);
        byte[] pTSByteArray = PTimestamp.INSTANCE.toBytes(sqlDate);
        return pTSByteArray;
    }

    public static byte[] encodeLong(String value)
    {
        byte[] pLongByteArray = PLong.INSTANCE.toBytes(value);
        return pLongByteArray;
    }

    public static byte[] encodeChar(String value)
    {
        byte[] pCharByteArray = PChar.INSTANCE.toBytes(value);
        return pCharByteArray;
    }

    public static byte[] encodeVarchar(String value)
    {
        byte[] pVarcharByteArray = PVarchar.INSTANCE.toBytes(value);
        return pVarcharByteArray;
    }

    public static byte[] encodeShort(String value)
    {
        Short shortValue = Short.parseShort(value);
        byte[] pShortByteArray = PSmallint.INSTANCE.toBytes(shortValue);
        return pShortByteArray;
    }

    public static byte[] encodeInteger(String value)
    {
        int intValue = Integer.parseInt(value);
        byte[] pIntByteArray = PInteger.INSTANCE.toBytes(intValue);
        return pIntByteArray;
    }


}